<?php

namespace App\Jobs;

use App\Http\Service\DeviceService;
use App\Model\Device;
use App\Model\DeviceWarning;
use App\Model\House;
use App\Utils\Result;
use Faker\Core\DateTime;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;


class SetPrice implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    private $device;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($device)
    {
        $this->device = $device;
        //因为要导入大文件 需要很久时间
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        try{
            $data = $this->device->makeFg();
            $service = app()->make(DeviceService::class);
            $result = $service->sendFgb($this->device->mac,$data);
        }catch (\Exception $e){
            Log::info($e->getMessage());
        }
    }
}

